

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;



class Person {

}

class Student extends Person {

}
public class Test {
    //杨辉三角
    public static List<List<Integer>> generate(int numRows) {
        //最终的数组也就是杨辉三角
        List<List<Integer>> ret = new ArrayList<>();
        //每一行的数组
        List<Integer> list = new ArrayList<>();
        list.add(1);//第一数组只有一个1，先放进去
        for (int i = 1; i < numRows; i++) {
            //最前面
            List<Integer> curRow = new ArrayList<>();//一行当中的
            curRow.add(1);
            //中间的数字
            List<Integer> preRow = ret.get(i-1);
                for (int j = 1; j < i; j++) {
                    int val = preRow.get(j) + preRow.get(j-1);
                    curRow.add(val);
                }

            //最后面的数字
            curRow.add(1);

            ret.add(curRow);
        }
        return ret;
    }

    public static void main(String[] args) {
        generate(5);
        System.out.println();
    }
    public static void func(String str1,String str2) {

        List<Character> ret = new ArrayList<>();
        //1.遍历一遍数组
        for (int i = 0; i < str1.length(); i++) {
            char ch = str1.charAt(i);
            if(!str2.contains(ch + "")) {
                //任何东西+上一个字符串都会变成字符串
                ret.add(ch);
            }
        }
        //打印删除后的字符
        for (int i = 0; i < ret.size(); i++) {
            System.out.print(ret.get(i));//打印i下标的值
        }
        System.out.println();

    }

    public static void main4(String[] args) {
        func("welcome bit","come");
    }
    public static void main3(String[] args) {
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.add("hello");
        arrayList.add("bit");
        arrayList.add("123");
        arrayList.add("nihao");
      /*  //截取下标1-3的内容
        List<String> str = arrayList.subList(1,3);
        System.out.println("=============");*/

        //ArrayList的遍历
        // 方法1
        System.out.println(arrayList);
        //2.for循环遍历
        for (int i = 0; i < arrayList.size(); i++) {
            System.out.print(arrayList.get(i) + " ");
        }
        System.out.println();
        //3.for-each
        for(String x : arrayList) {
            System.out.print(x + " ");
        }
        //迭代器
        Iterator<String> it = arrayList.listIterator();
        while(it.hasNext()) {
            System.out.println(it.next() + "");
        }
    }
    public static void main2(String[] args) {
        ArrayList<Student> arrayList = new ArrayList<>();

        List<Person> list = new ArrayList<>(arrayList);

    }
    public static void main1(String[] args) {
        //ArrayList<Integer> arrayList = new ArrayList<>();
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.add("hello");
        arrayList.add("bit");


        List<String> list = new ArrayList<>();//这个不能调用子类的特有方法

        list.add("hello");

        //一次性将hello bit 放入到list当中
        list.addAll(arrayList);
        //删除某个位置的元素，并且能够记录所删除元素的内容
        String ret = list.remove(1);
        //删除某个对象
        Boolean ret1 = list.remove("hello");
        //指定位置更换为指定内容
        String ret2 = list.set(0,"Nmj");
        //clear是清空
        list.clear();
        System.out.println("以上代码能够运行并且没有报错");



    }
}
